package com.dragon.english_practice_back.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
 * token使用信息
 * @TableName token_usage
 */
@TableName(value ="token_usage")
@Data
public class TokenUsage implements Serializable {
    /**
     * 唯一标识
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 总token
     */
    @TableField(value = "total_tokens")
    private Integer totalTokens;

    /**
     * prompt使用的token
     */
    @TableField(value = "prompt_tokens")
    private Integer promptTokens;

    /**
     * AI回复使用的token
     */
    @TableField(value = "completion_tokens")
    private Integer completionTokens;

    /**
     * 消耗时间
     */
    @TableField(value = "completion_time")
    private Date completionTime;

    /**
     * 为了谁服务
     */
    @TableField(value = "for_user_id")
    private Integer forUserId;

    /**
     * 服务类型
     */
    @TableField(value = "service_type")
    private String serviceType;

    /**
     * 使用的模型
     */
    @TableField(value = "model")
    private String model;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        TokenUsage other = (TokenUsage) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getTotalTokens() == null ? other.getTotalTokens() == null : this.getTotalTokens().equals(other.getTotalTokens()))
            && (this.getPromptTokens() == null ? other.getPromptTokens() == null : this.getPromptTokens().equals(other.getPromptTokens()))
            && (this.getCompletionTokens() == null ? other.getCompletionTokens() == null : this.getCompletionTokens().equals(other.getCompletionTokens()))
            && (this.getCompletionTime() == null ? other.getCompletionTime() == null : this.getCompletionTime().equals(other.getCompletionTime()))
            && (this.getForUserId() == null ? other.getForUserId() == null : this.getForUserId().equals(other.getForUserId()))
            && (this.getServiceType() == null ? other.getServiceType() == null : this.getServiceType().equals(other.getServiceType()))
            && (this.getModel() == null ? other.getModel() == null : this.getModel().equals(other.getModel()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getTotalTokens() == null) ? 0 : getTotalTokens().hashCode());
        result = prime * result + ((getPromptTokens() == null) ? 0 : getPromptTokens().hashCode());
        result = prime * result + ((getCompletionTokens() == null) ? 0 : getCompletionTokens().hashCode());
        result = prime * result + ((getCompletionTime() == null) ? 0 : getCompletionTime().hashCode());
        result = prime * result + ((getForUserId() == null) ? 0 : getForUserId().hashCode());
        result = prime * result + ((getServiceType() == null) ? 0 : getServiceType().hashCode());
        result = prime * result + ((getModel() == null) ? 0 : getModel().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", totalTokens=").append(totalTokens);
        sb.append(", promptTokens=").append(promptTokens);
        sb.append(", completionTokens=").append(completionTokens);
        sb.append(", completionTime=").append(completionTime);
        sb.append(", forUserId=").append(forUserId);
        sb.append(", serviceType=").append(serviceType);
        sb.append(", model=").append(model);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}